﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Collections.ObjectModel;
using HigLabo.WindowsAzure.RestService.Extensions;

namespace HigLabo.WindowsAzure.RestService.ServiceManagement
{
    public class Certificates
    {
        public static readonly String ElementName = "Certificates";

        private Collection<Certificate> _Certificates = new Collection<Certificate>();
        public IEnumerable<Certificate> CertificateList
        {
            get { foreach (var item in _Certificates) { yield return item; } }
        }

        public Certificates(XElement xml)
        {
            IEnumerable<XElement> els;
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }
            /*Certificate*/
            els = xml.ElementsByLocalName(Certificate.ElementName);
            foreach (var item in els)
            {
                var add = new Certificate(item);
                this._Certificates.Add(add);
            }
        }

    }
}
